Pi-based spectrometer puts complexity in the software | Hacker Day

2021-11-25 10:48:31 By : Ms. Sola Xu

If you use optics for a long time, sooner or later you may want a spectrometer. However, optical instruments are notoriously expensive, at least for high-quality equipment. But a useful spectrometer, such as this DIY Raspberry Pi-based instrument, does not necessarily go bankrupt.

This one was found through [Les Wright], and we have always admired his homemade laser. [Les] By keeping the optical components super simple, we managed to minimize the cost. The front end of the instrument is just a hand-held diffraction grating spectrometer, which is used in physics classrooms to demonstrate the spectral characteristics of different light sources. Changing it from a spectrometer to a spectrometer requires a Raspberry Pi and a camera; mounted on the lens and positioned to view the spectrum produced by the diffraction grating, the camera sends the data to the Pi, where the Python program converts the spectrum into data. [Les]’s software is simple and complete, giving a graphical representation of the spectral data it sees. The video below shows what is involved in the construction process and calibration of the spectrometer, as well as some of the more interesting spectra that can be easily explored.

We appreciate the simplicity and practicality of this design, as well as its adaptability. The spectroscope holder and Pi cam holder can easily become a 3D printer, instead of using machined aluminum, we can also see how the software can be applied to PCs and webcams.

Nice hardware/software project and well explained

You have an email address, can I write to you with some technical questions? Thanks, will

Cheers, glad you like it!

Oops, man, this is what every project documentation should be! I don't need a spectrometer, but it seems easy to build and get 2-3nm and buy something 15nm. Keep up the good work Les!

Thanks! When I decided to build, I honestly was surprised that no one wrote software for Pi! Judging from the comments on YouTube and the requests on GitHub, this thing will get more arms and legs. cheers!

Can this be used as a spectrophotometer?

Of course, I don't understand why not! You need a known broadband light source. If you are so inclined, you can modify the software to flatten the initial curve and let it detect drops instead of peaks.

The software has not been refactored yet (it is still in progress), so it is not very tidy inside, but the source code has been well commented from beginning to end. At present, as the initial version, there are not so many bells and whistles, so it is not too complicated to understand.

If you shrink it slightly, it will be a good addition to one of those "three-axis instruments in real life".

I came here to talk.

They seem to be very popular recently. It will be interesting to see how small a beam splitter you can build. Hamamatsu did it, so be careful, it is possible to use a mini Pikam and a stable hand!

> They seem to be very popular recently.

Well, exploring previously unexplored planets is becoming more and more common, so being able to assess safety and analyze any strange things found there is indeed a practical need.

In addition, everyone owns a smartphone, and they will immediately provide you with half of the items for free, so this must also help.

complete! : https://www.youtube.com/watch?v=Tw3HJEhE2dI

genius! Thanks for the link!

You can use some optics (microscope lenses) and stepping motors to increase its resolution to a very extreme level:

Add a mirror to the shaft of the stepper motor so that you can use the stepper motor to select the part of the spectrum that the camera points to, and use the microscope to install the camera (you can only use one of the USB microscope cameras, I have some, they are very, very Neat) "Zoom in" to that part of the spectrum.

In this way, you can tell your stepper motor to "turn 53 degrees", which in turn means "focus the area from 301 nm to 303 nm", and the microscope allows you to really see the area close to it.

Now you are no longer limited to viewing all spectra at the same time using one frame of the camera.

You can use one frame and stepper motor position/angle in each spectrum range, and you can even use video capture to capture all the spectrum in a few seconds (by using a stepper motor to "scan" while recording a video).

In this way, you only need to add a stepper motor and a lens, and your spectral resolution will increase dozens or even hundreds of times.

I think it's fairly simple, I don't see where it can go wrong or become too complicated (assuming enough care in the assembly process), I hope I have free time to actually perform this operation, it sounds interesting.

Yes, it is certainly possible, but I suspect that the pocket oscilloscope I am using will not work. The resolution will ultimately be determined by the diffraction grating. See: http://hyperphysics.phy-astr.gsu.edu/hbase/phyopt/gratres.html

In other words, using a customized spectrometer, your suggestions can fully meet the needs of amateurs.

Yes, currently my lack of free time is part of the reason for the simplicity of the build, but I will continue to work hard. I hope others will too. Amateur astronomers, physicists and chemists are very interested in this, so I hope people have time to meet their needs.

Mind trying to make a "layman" explanation of the resolution limit?

The link did not really help me.

In addition, what is wrong with the "pocket oscilloscope" you are using?

Regarding "others will also", do you plan to publish your plan and other project files to github so that others can try to copy your work and possibly improve it, in a way that you might benefit from Way to share their progress? You know, the whole open source thing.

If you want a free Smoothieboard to control a stepper motor, or any other items you may have, please don't hesitate to ask me, I would be happy to help with this hardware, or I can help in any other way.

The diffraction grating is composed of engraved or etched lines on the substrate. The more lines per millimeter, the higher the resolution. Although the pocket oscilloscope is cool, it is unlikely to have a grating of more than 1000 lines/mm, and the field of view is very narrow, so for the situation you describe, you need to build a customized spectrometer.

Yes, it is linked to in the video description: https://github.com/leswright1977/PySpectrometer

Cheers, if it turns out to be that way, I will definitely ask.

It sounds like you should be able to use something other than diffraction gratings, such as more traditional optical prisms, and resolve this limitation with a resolution limited only by the zoom of the microscope, right?

Also, thank you very much for your explanation.

The number of grating lines used in dispersion limits the resolution. Look at the slit experiment from physics. One slit, then two slits, then many slits. Since the more fringes that light is diffracted, the higher the wavelength dispersion resolution in the far field.

You will also reach the point where the resolution of the spectrometer is limited by the angular range of the input slit width. Make the slit narrower, and you do not have enough light to make the camera have a high signal-to-noise ratio. Make the slit too wide, and the angle formed by the light at the edge of the slit will cause different wavelengths to overlap at the detector.

thank you for the explanation!

There is something about using thermally cut segments from recordable dead blue light as a beam splitter. I know that DVD is also suitable for this, but the angle is smaller.

So, how to calibrate the amplitude? I doubt whether the pi cam sensor has a flat frequency response. The OpenCV BGR2GRAY conversion must also be considered.

Maybe point it to the sun?

The sun is not a good reference: https://en.wikipedia.org/wiki/Sunlight#/media/File:Spectrum_of_Sunlight_en.svg

Incandescent bulb? But the "ultimate light bulb test" in popular mechanics shows that even these have different spectra (I guess because of glass).

Not only the camera, but also the entire setup. The diffraction grating itself and any lens must be taken into account in the calibration. It is not easy or cheap to obtain an ultra-stable broad-spectrum light source with an accurate known spectrum...

Are you asking about the peak amplitude or relative spectral position?

If the latter, find a fluorescent lamp that still contains mercury. The mercury emission line is sharp and has a clear position on the short side of the spectrum. This method was used in the era of monochromators (only actual lamps containing pure mercury vapor were used).

However, if you are talking about amplitude (ie peak intensity), then I am afraid you are out of luck. This is difficult to achieve...

Good comment guys. The response is not completely flat, but not unreasonable, the link is here: https://www.scivision.dev/raspberry-pi-ov5647-camera-spectral-response/ For qualitative amplitude measurement, it is good. These are color cameras, so they have an RGB filter on the silicon. At least one university managed to take one out of picam to do UV work, but the process seemed like a chore.

For "real" spectrometers, a linear black-and-white CCD is used with a known authentication response curve.

The "standard" light source is something that needs to be studied. They definitely exist!

I would buy two cheap 25-cent LEDs at both ends of the spectrum. Just like calibrating a pH meter, once you have two known reference points, you are done. As long as there is a clear peak, it doesn't matter how dirty the emissions are. Therefore, the red LED is about 680nm, and the blue LED is about 450nm. Therefore, please give priority to buying LEDs with known emission spectra. You absolutely don't need to be perfect, because it is repeatable. Repeatability is far more important than accuracy. Then start recording data. Now... someone should illuminate the fruit (perhaps cantaloupe) with a full-spectrum flashlight and record the reflectance spectrum and how sweet it tastes. Once you have determined the best spectral response of the perfect fruit, you can take the flashlight and spectrophotometer to the farmers’ market and shop in a geeky way: P As long as you draw a scatter plot of peak emission, the surrounding light is irrelevant The fruit is critical. Your flashlight will not match the background light. However, the Shroud will definitely help. This absorbance method is suitable for any detection. You can measure the nutritional deficiencies of the lawn, the health of the aquarium water, the matching of paint color samples, the types of leaves, etc. The most important component is the reference data. Okay, I will stop now.

The sun does a great job as a cheap test source. Otherwise, high-temperature halogen tungsten bulbs are reasonable. NIST has good free reference papers in this area. They have very expensive calibration sources, but for quick hobby purposes, this is not necessary.

You can easily find the relative magnitude in a variety of ways. One is to use a reference source and subtract it from your sample spectrum. Or use the ratio between the reference and the sample. By using a rotating mirror to chop the signal, the differential method is incorporated into the operation of some classic absorption spectrometers. One path leads directly to the detector, and the other path passes through the sample material. If you use the ratio of these two signals, it will automatically compensate for changes in the light source. (Actually, in the old school system, feedback is used to get the output from the differential scheme. The variable aperture driven by the servo is used to make the reference beam and the sample path have the same amplitude. Then the motor drive becomes the output spectrum.)

In this device, the photodiode can be used as a broadband detector, which can observe the same light source as the spectrometer and serve as a reference. This is indeed a neat project with huge opportunities for change.

What can be used to characterize the long wave of unknown IR LEDs? This setting seems to peak around 650/700nm, when the 700/1000nm range is necessary for IR.

When calibrating, the software will calculate the scale, scale line and label, so you can easily set it to 700-1000nm. The spectroscope itself may not go that far. If I have time, I will test it.

The camera may not be very effective at detecting light above about 800-850 nm. My guess is that it looks like dark camera noise above about 800 nm.

If you remove the infrared filter, it won't.

Silicon responds up to about 1100 nm. Of course quantitative easing can be bad, but you get more than just noise. If you can cool the sensor, so much the better.

I built a similar spectrometer using slits and 1000 lines/mm diffraction grating instead of the beautiful spectrometer used by Les Wright. I used a raspberry pi high-quality camera with the IR filter removed, and the resulting spectrometer seemed to be useful in the range of about 350nm to about 1200nm. It does a very good job of classifying 720nm, 780nm, 850nm and 940nm LEDs.

Is it possible that you have recorded this somewhere? I am trying to develop a plan for a diy spectrometer that covers the visible spectrum in the 900-1000 range.

Many scientific measurements are ratio measurements—that is, you use a light source and a "white" reflector to measure the system response ("background" or "reference"), or measure the spectral source in transit ("open beam" or "reference") The reflection is reflected from the sample, or transmitted by the sample. Then you compare the sample/reference. If you take the negative logarithm, you will end up with absorbance units, which have a linear relationship with concentration. This is the method of quantitative colorimetric analysis (for example, drinking water). Check out any basic books on the ultraviolet-visible spectrum (or near-infrared, mid-infrared, etc.). See also: https://publiclab.org/

You can also use cross-transmission gratings to improve spectral resolution and dynamic range. Please refer to: https://www.spectroclick.com/

If you want to use a smartphone as a detector (ie a camera), then look at: https://www.sciencedaily.com/releases/2019/06/190624120237.htm The smartphone does a lot of processing the camera data before you see it It, so you need to intercept data at the earliest possible stage!

Dear Les, I really like your video and remade pyspectrometer. It works very well. I want to use it to record electrochemiluminescence in the physical chemistry laboratory. Next, I will turn to your dye laser project. The best dessert from Germany, Achim

Please be kind and respectful to help make the comment section great. (Comment Policy)

This website uses Akismet to reduce spam. Learn how to handle your comment data.

By using our website and services, you explicitly agree to the placement of our performance, functionality and advertising cookies. learn more